﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml.Serialization;

namespace MyMovieInfo
{
    class XMLPersistenceService : IPersistenceService
    {
        private string _filename;
        public XMLPersistenceService(string filename)
        {
            _filename = filename;
        }

        public void SaveMovieList(List<Movie> movies)
        {
            XmlSerializer xmlserializer = new XmlSerializer(typeof(List<Movie>));
            using (StreamWriter streamwriter = new StreamWriter(_filename))
            {
                xmlserializer.Serialize(streamwriter, movies);
                streamwriter.Close();
            }
        }
    }
}
